home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / libtools.arc / GETSCR.AQM / GETSCR.ASM
Encoding:
Assembly Source File  |  1984-04-08  |  3.4 KB  |  86 lines

  1.     page    ,132
  2.     title BASIC GET SCREEN LINE SUBROUTINE - by John R. Hind  V0.0
  3. ; This subroutine is called from basic to obtain a string of data
  4. ; or atribute characters for a given line of the screen using the
  5. ; statement "call getscr(lineflag,stringv$) " where getscr is an
  6. ; integer variable containing the varptr value of an array element
  7. ; into which this subroutine was loaded via a "BLOAD" statement.
  8. ; lineflag is an integer whoes low order byte specifies the line
  9. ; which is to be returned and whoes high order byte is a flag which
  10. ; if non-zero indicates that the atribute characters rather than 
  11. ; data characters are to be placed in the passed stringv$ area. The
  12. ; size of the string$ should be preset to the number of characters
  13. ; desired but must be less than or equal to the width of the screen.
  14. ;    The segment which follows defines a "BLOAD" file immage containing
  15. ; self relocating code (can be moved to any offset and executed) which
  16. ; is loaded into an array area by the calling basic program prior to
  17. ; its use. The size of the array is set using a "DIM" statement such
  18. ; that the number of elements * the size of an element ( 2 bytes for
  19. ; an integer) is big enough to hold the number of bytes described
  20. ; by the "bllen" word of the bload file immage below.
  21. ;   A BLOAD file is created by placing the resulting  load module
  22. ; under debug and writing starting at DS:102 for a length shown in
  23. ; the word at lable bwrt ( DS:100) into a file named by the N command.
  24. ; The following command sequence is used:
  25. ;    DEBUG GETSCR.EXE
  26. ;    -D 100
  27. ;    04A1:0100  80 00 FD 00 B8 00 00 48 00 BB EC 8A 3E 49 00 B4 ...
  28. ;    04A1:0110  03 ..............
  29. ;    -N GETSCR.BLD
  30. ;    -R CX
  31. ;    CX 0000
  32. ;    :80
  33. ;    -W 04A1:102
  34. ;    -Q
  35. ;
  36. bload    segment
  37.     assume cs:bload,ds:nothing,es:nothing,ss:nothing
  38.     ;the next word contains the proper BLOAD file length
  39. bwrt    dw ((endgs-blintro+127)/128)*128 ; length to write bload file
  40.     ;start of a bload file immage of above length
  41.     page
  42. blintro db 0fdh    ; first byte of bload file
  43. blseg    dw 0b800h    ; bload file default segment
  44. bloff    dw 0        ; bload file default offset
  45. bllen    dw endgs-getscr    ; number of bytes to bload
  46. getscr    proc far    ; entry point of BASIC CALL routine
  47.     mov bp,sp    ;set up addresing of call parms
  48. stringp    equ [bp]+4    ;pointer to string descriptor
  49. linep    equ [bp]+6    ;pointer to lineflag integer
  50.     mov bh,ds:49h    ;get active page number
  51.     mov ah,3    ;bios request code for get cursor
  52.     int 10h        ;video io request
  53.     push dx        ;save curent cursor position
  54.     mov bx,stringp    ;get addr of string descriptor
  55.     mov cx,0    ;clear counter register
  56.     mov cl,[bx]    ;set counter to string length
  57.     mov di,[bx]+1    ;addr of string
  58.     mov bx,linep    ;get addr of lineflag
  59.     mov bx,[bx]    ;get lineflag
  60.     xchg bl,bh    ;bl is flag and bh is line # in basic
  61.     mov dh,bh    ;put line # into high order of cursor reg
  62.     dec dh         ;make it into a video row number
  63.     mov dl,0    ;set to first col on screen
  64. lp1:    mov bh,ds:49h
  65.     mov ah,2    ;set cursor request code
  66.     int 10h
  67.     inc dl        ;next col
  68.     mov ah,8    ;read request code
  69.     int 10h
  70.     test bl,0ffh    ;atribute byte or character ?
  71.     jz chr
  72.     xchg al,ah    ;atribute byte
  73. chr:    stosb        ;save byte and increment pointer
  74.     loop lp1
  75.     pop dx        ;get value of original cursor 
  76.     mov bh,ds:49h
  77.     mov ah,2    ;set cursor request code
  78.     int 10h        ;restore cursor
  79. ;
  80.     ret 4        ; return to the BASIC program
  81. getscr    endp
  82.     db 1ah    ;end of file mark in bload file
  83. endgs    db "<end of bload file>"
  84. bload ends
  85.     end
  86.